﻿using IconYuan.Model.Entity.Products;
using SqlSugar;
using System;

namespace IconYuan.Model.Products
{
    /// <summary>
    /// 商品基础信息
    /// </summary>
    [SugarTable("t_goods")]
    public class GoodsBase
    {
        /// <summary>
        /// 自增
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] //是主键, 还是标识列
        public int goods_id { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string goods_name { get; set; }
        /// <summary>
        /// 分类id
        /// </summary>
        public int category_id { get; set; }      
        /// <summary>
        /// 商品状态 (10上架 20下架)
        /// </summary>
        public int status { get; set; } = 10;
        /// <summary>
        /// 商品规格 (10单规格 20多规格)
        /// </summary>
        public int spec_type { get; set; }
        /// <summary>
        /// 商品价格 (最低)
        /// </summary>
        public decimal goods_price_min { get; set; }
        /// <summary>
        /// 商品价格 (最高)
        /// </summary>
        public decimal goods_price_max { get; set; }
        /// <summary>
        /// 划线价格 (最低)
        /// </summary>
        public decimal line_price_min { get; set; }
        /// <summary>
        /// 体验价(不参与其他优惠)
        /// </summary>
        public decimal sale_price { get; set; }
        /// <summary>
        /// 价格单位描述
        /// </summary>
        public string price_desc { get; set; }
        /// <summary>
        /// 库存总量 (包含所有sku)
        /// </summary>
        public int stock_total { get; set; }
        /// <summary>
        /// 库存计算方式(10下单减库存 20付款减库存)
        /// </summary>
        public int deduct_stock_type { get; set; }
        /// <summary>
        /// 是否开启积分赠送 (1开启 0关闭)
        /// </summary>
        public int is_points_gift { get; set; } = 1;
        /// <summary>
        /// 需要兑换的积分
        /// </summary>
        public int points{ get; set; } = 0;     
        /// <summary>
        /// 是否开启等级折扣 (1开启 0关闭)
        /// </summary>
        public int is_enable_grade { get; set; } = 0;
        /// <summary>
        /// 等级折扣设置 (0默认等级折扣 1单独设置折扣)
        /// </summary>
        public int is_alone_grade { get; set; } = 0;
        /// <summary>
        /// 是否开启单独分销 (0关闭 1开启)
        /// </summary>
        public int is_ind_dealer { get; set; } = 0;
        /// <summary>
        /// 分销佣金类型 (10百分比 20固定金额)
        /// </summary>
        public int dealer_money_type { get; set; }
        /// <summary>
        /// 商品卖点
        /// </summary>
        public string selling_point { get; set; } = string.Empty;
        /// <summary>
        /// 商品主图url
        /// </summary>
        public string goods_image { get; set; } = string.Empty;
        /// <summary>
        /// 初始销量
        /// </summary>
        public int sales_initial { get; set; } = 0;
        /// <summary>
        /// 实际销量
        /// </summary>
        public int sales_actual { get; set; } = 0;
        /// <summary>
        /// 是否删除
        /// </summary>
        public int is_delete { get; set; } = 0;
        /// <summary>
        /// 店铺id
        /// </summary>
        public int store_id { get; set; } = 0;
        /// <summary>
        /// 门店id
        /// </summary>
        public int shop_id { get; set; } = 0;
        /// <summary>
        /// 排序: 数字越小越靠前
        /// </summary>
        public int sort { get; set; } = 0;
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime create_time { get; set; }
    }


    /// <summary>
    /// 商品完整信息
    /// </summary>
    [SugarTable("t_goods")]
    public class Goods : GoodsBase
    {
        /// <summary>
        /// 商品编码
        /// </summary>
        public string goods_no { get; set; }
        /// <summary>
        /// 划线价格 (最高)
        /// </summary>
        public decimal line_price_max { get; set; }

        /// <summary>
        /// 分销佣金 (一级)
        /// </summary>
        public decimal first_money { get; set; }
        /// <summary>
        /// 分销佣金 (二级)
        /// </summary>
        public decimal second_money { get; set; }
        /// <summary>
        /// 分销佣金 (三级)
        /// </summary>
        public decimal third_money { get; set; }
        public DateTime update_time { get; set; }
        /// <summary>
        /// 配送模板ID
        /// </summary>
        public int delivery_id { get; set; }
        /// <summary>
        /// 主图视频ID
        /// </summary>
        public int video_id { get; set; }
        /// <summary>
        /// 主图视频封面ID
        /// </summary>
        public int video_cover_id { get; set; }
        /// <summary>
        /// 商品详情
        /// </summary>
        public string content { get; set; }
        ///// <summary>
        ///// 单独设置折扣的配置
        ///// </summary>
        //public string alone_grade_equity { get; set; } = string.Empty;
        ///// <summary>
        ///// 显示销量 (初始销量 + 实际销量)
        ///// </summary>
        //public int goods_sales { get; set; }
        ///// <summary>
        ///// 是否使用会员等级折扣价（判断登录用户的会员等级）
        ///// </summary>
        //public bool is_user_grade { get; set; } = true;
    }


    /// <summary>
    /// 待结算商品
    /// </summary>
    [SugarTable("t_goods")]
    public class CheckOrderGoods : GoodsBase
    {
        /// <summary>
        /// 商品单价
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public decimal goods_price { get; set; }
        /// <summary>
        /// 购买数量
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public int buy_count { get; set; }

        [SugarColumn(IsIgnore = true)]
        public Sku skuInfo { get; set; }
    }
}